< previous page page_383 next page >

Page 383
e10a6a0a59f035e870d90cca05b85fce.gif
        End If
        If Wymax > DataYmax And Wymin > DataYmin Then
            ' Adjust upward.
            Wymin = Wymin + DataYmax - Wymax
            Wymax = DataYmax
        End If
    End If

    ' Map the world window to the viewport.
    picViewport.ScaleLeft = Wxmin
    picViewport.ScaleTop = Wymax
    picViewport.ScaleWidth = Wxmax - Wxmin
    picViewport.ScaleHeight = Wymin - Wymax

    ' Force the viewport to repaint.
    picViewport.Refresh

    ' Reset the scroll bars.
    IgnoreSbarChange = True
    HScrollBar.Visible = (wid < DataXmax - DataXmin)
    VScrollBar.Visible = (hgt < DataYmax - DataYmin)

    ' The values of the scroll bars will be where
    ' the top/left of the world window should be.
    VScrollBar.Min = 100 * (DataYmax)
    VScrollBar.Max = 100 * (DataYmin + hgt)
    HScrollBar.Min = 100 * (DataXmin)
    HScrollBar.Max = 100 * (DataXmax - wid)

    ' SmallChange moves the world window 1/10
    ' of its width/height.
    VScrollBar.SmallChange = 100 * (hgt / 10)
    VScrollBar.LargeChange = 100 * hgt
    HScrollBar.SmallChange = 100 * (wid / 10)
    HScrollBar.LargeChange = 100 * wid

    ' Set the current scroll bar values.
    VScrollBar.Value = 100 * Wymax
    HScrollBar.Value = 100 * Wxmin

    IgnoreSbarChange = False
End Sub
Example program Panview1 lets you zoom and pan to examine a picture of a smiley face. You can change the magnification by a factor of 2, 4, 1/2, or 1/4 in addition to returning to full scale. Zoom in and experiment with the scrollbars. Click on the arrow buttons and between the buttons and the thumb to see how the SmallChange and LargeChange properties affect the scrollbars. Drag the thumb to watch the picture scroll as you change the scrollbars' values.

 
< previous page page_383 next page >